// services/analysisService.js
import {hostAddr} from '@/config.js';

export async function evaluatePronunciation(messageId, audioFile) {
  const data = new FormData();
  data.append('audio', audioFile);
  data.append('message_id', messageId);

  const url = `${hostAddr}/pronunciation/evaluation`;
  const response = await fetch(url, {
    method: 'POST',
    body: data,
  });

  return await response.json();
}

export async function saveAnalysisResult(messageId, category, content) {
  const url = `${hostAddr}/analysis`;
  const response = await fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      message_id: messageId,
      category,
      content
    })
  });

  return await response.json();
}